﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ZF.BLL.UserControls
{
    public class PlaceHolder : System.Web.UI.WebControls.PlaceHolder
    {
        /// <summary>
        /// 绑定页面操作类型，如果设置该值，那么只有在页面为与之对应的行为相匹配才会显示该控件
        /// </summary>
        public PageOperType? BindOper { get; set; }
        /// <summary>
        /// 根据页面的行为是判断是否显示控件
        /// </summary>
        private void SetVisibleByOperType()
        {
            if (this.Page is BLL.Page.PageBase)
            {
                var operPage = (BLL.Page.PageBase)Page;
                if (BindOper != null)
                {
                    PageOperType bindOper = (PageOperType)BindOper;
                    this.Visible = (operPage.OperType & bindOper) == bindOper;
                }
            }
        }
        public PlaceHolder()
            : base()
        {
            this.Init += delegate(object sender, EventArgs e)
            {
                SetVisibleByOperType();
            };
        }

        
    }
}
